/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package supportlearning.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author Huy
 */
@Entity
@Table(name = "StudentProfile", catalog = "SupportLearningDB", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "StudentProfile.findAll", query = "SELECT s FROM StudentProfile s"),
    @NamedQuery(name = "StudentProfile.findByStudentId", query = "SELECT s FROM StudentProfile s WHERE s.studentId = :studentId"),
    @NamedQuery(name = "StudentProfile.findByDescription", query = "SELECT s FROM StudentProfile s WHERE s.description = :description")})
public class StudentProfile implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "StudentId", nullable = false, length = 50)
    private String studentId;
    @Column(name = "Description", length = 100)
    private String description;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "studentProfile", fetch = FetchType.EAGER)
    private List<StudentResult> studentResultList;
    @JoinColumn(name = "ClassId", referencedColumnName = "ClassId", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private CMSClass cMSClass;
    @JoinColumn(name = "StudentId", referencedColumnName = "AccountId", nullable = false, insertable = false, updatable = false)
    @OneToOne(optional = false, fetch = FetchType.EAGER)
    private Account account;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "studentProfile", fetch = FetchType.EAGER)
    private List<FeedBack> feedBackList;

    public StudentProfile() {
    }

    public StudentProfile(String studentId) {
        this.studentId = studentId;
    }

    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<StudentResult> getStudentResultList() {
        return studentResultList;
    }

    public void setStudentResultList(List<StudentResult> studentResultList) {
        this.studentResultList = studentResultList;
    }

    public CMSClass getCMSClass() {
        return cMSClass;
    }

    public void setCMSClass(CMSClass cMSClass) {
        this.cMSClass = cMSClass;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public List<FeedBack> getFeedBackList() {
        return feedBackList;
    }

    public void setFeedBackList(List<FeedBack> feedBackList) {
        this.feedBackList = feedBackList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (studentId != null ? studentId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof StudentProfile)) {
            return false;
        }
        StudentProfile other = (StudentProfile) object;
        if ((this.studentId == null && other.studentId != null) || (this.studentId != null && !this.studentId.equals(other.studentId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "supportlearning.entities.StudentProfile[studentId=" + studentId + "]";
    }

}
